home *** CD-ROM | disk | FTP | other *** search
- /***
- * PageMon.c
- *
- * This file contains the coor overrides for the messageing that is needed to implement
- * the page monitor extension
- *
- * Gordon Watts March, 1994
- *
- ***/
- #include "Headers.h"
-
- #include "PageMon.h"
- #include "Exceptions.h"
- #include "logIO.h"
-
- /**
- ** Instance vars for this job. These are kept round during the imaging of the job
- **/
-
- typedef struct {
- long pagesImaged;
- } pageMonInstanceVars, *pageMonInstanceVarsPtr, **pageMonInstanceVarsHdl;
-
- /**
- * PageMonImageJob
- *
- * We count the number of pages here, and write them out to a file
- *
- **/
- OSErr PageMonImageJob ( gxSpoolFile thePrintFile, long *closeOptions)
- {
- OSErr anErr;
- pageMonInstanceVarsHdl theVars;
-
- /**
- ** Allocate some instance vars for this job...
- **/
-
- theVars = (pageMonInstanceVarsHdl) NewHandle (sizeof (pageMonInstanceVars));
- (*theVars) -> pagesImaged = 0;
-
- SetMessageHandlerInstanceContext (theVars);
-
- /**
- ** Now, just send on the Image Job message and get it all over with!
- **/
-
- anErr = Forward_GXImageJob (thePrintFile, closeOptions);
-
- /**
- ** Now that the job has been imaged (noErr or otherwise return), write out the
- ** page count, deallocate the instance var memory, and reset the instance
- ** handle so GX doesn't get confused.
- **/
-
- WriteToLog ((*theVars) -> pagesImaged);
-
- SetMessageHandlerInstanceContext (0L);
- DisposHandle ((Handle) theVars);
-
- /**
- ** Done!
- **/
-
- return anErr;
- }
-
- /**
- * PageMonImagePage
- *
- * Image a single page. For us, we just increment the count of pages after doing the default
- * behavior!
- *
- **/
- OSErr PageMonImagePage (gxSpoolFile theSpoolFile, long pageNumber, gxFormat theFormat,
- void *imageData)
- {
- OSErr theErr;
- pageMonInstanceVarsHdl theVars;
-
- /**
- ** First, image the page
- **/
-
- theErr = Forward_GXImagePage (theSpoolFile, pageNumber, theFormat, imageData);
- nrequire (theErr, FailedGXImagePage);
-
- /**
- ** Retreive (sp?) our instance variables
- **/
-
- theVars = GetMessageHandlerInstanceContext();
- require (theVars != 0, FailedGetVars);
-
- (*theVars) -> pagesImaged += 1;
-
- /**
- ** Done!
- **/
-
- FailedGetVars:
- FailedGXImagePage:
- return theErr;
- }